import { defineStore } from "pinia";

export const useOrderStore = defineStore('orders',{
    state:()=>({  //数据
        orders:[]  //存储订单数据
    }),
    actions:{    //方法
        addOrder(order){
            this.orders.push(order)
        },
        removeOrder(orderId){
            this.orders = this.orders.filter(o => o.orderId != orderId)
        }
    },
    getters:{  //获取值
        totalOrders:(state)=>state.orders.length  //返回订单总数量
    }
})